Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgraded trust-dns-resolver (#92) #105

Merged
merged 5 commits into from
Jan 10, 2020
Merged

Upgraded trust-dns-resolver (#92) #105

merged 5 commits into from
Jan 10, 2020

Conversation

bigtoast
Copy link
Contributor

@bigtoast bigtoast commented Jan 10, 2020

This is my first pull request in Rust so feel free to be brutal. All the tests pass and I am able to turn on and off dns resolution on my machine (Fedora 31). Thanks for labelling the issue as a good one to start on. I like this project and would like to help out more as a good way to get some Rust experience. I have a lot of async programming experience but Rust's memory model is a bit out of left field for me.

(edited to add this)
Closes #92

@imsnif imsnif requested a review from ebroto January 10, 2020 07:01
@ebroto
Copy link
Collaborator

ebroto commented Jan 10, 2020

Hey @bigtoast, thanks for the PR!

I can't right now, but I'll take a look at it tonight (GMT+1)

Copy link
Collaborator

@ebroto ebroto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @bigtoast, I think this is great for a first PR in Rust!

I suggested some minor changes. Also main.rs seems to be executable now, can we change it back to 0644?

Looking forward to merge this!

CONTRIBUTING.md Show resolved Hide resolved
src/os/shared.rs Outdated
let mut runtime = Runtime::new()?;
let resolver = runtime
.block_on(dns::Resolver::new(runtime.handle().clone()))
.unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this unwrap() and use a question mark here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this change but for my own edification, can you expand on the reasoning for it? I am certainly new to the idioms and best practices for Rust.

Copy link
Collaborator

@ebroto ebroto Jan 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I will try my best!

unwrap() will try to access the value inside the Result and will panic in case of error. The question mark will desugar to a match statement that, in case of error, will return early from the function. Another nice thing from the ? is that it will try to convert the unwrapped error into the error type in the return value of the signature, in case the latter implements From for that error.

You can read more here and here.

unwrap is usually frowned upon because it does not allow handling the error gracefully.

src/network/dns/resolver.rs Outdated Show resolved Hide resolved
src/network/dns/resolver.rs Outdated Show resolved Hide resolved
src/tests/fakes/fake_input.rs Show resolved Hide resolved
@bigtoast
Copy link
Contributor Author

@ebroto Thanks for the review. I made the requested changes.

@ebroto
Copy link
Collaborator

ebroto commented Jan 10, 2020

Thanks for your fast response! I think that everything has been fixed except for the permissions of the main.rs file. Just this and we're good to go :)

EDIT: It seems you did that faster than I wrote it :) Just let the CI pass and then we can merge.

@ebroto
Copy link
Collaborator

ebroto commented Jan 10, 2020

Thanks for your contribution, feel free to take another one if you wish :)

@ebroto ebroto merged commit c14bdf7 into imsnif:master Jan 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade trust-dns-resolver to 0.18
2 participants